<!DOCTYPE html>

<html>
  <head>
 
    
    <title>My JSP 'index.jsp' starting page</title>

	<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>

  </head>
  
  <body>
   Welcome. <br>
    <table id="table" border="1">
    	<tr>
    		<th>id</th>
    		<th>username</th>
    		<th>password</th>
    		<th>����</th>
    	</tr>
    	
    </table>
   
    <script>
    
    function del(userid){
		$.get("${pageContext.request.contextPath}/system/user/delUser?userid=" + userid,function(data){
			if("success" == data.result){
				alert("ɾ��ɹ�");
				window.location.reload();
			}else{
				alert("ɾ��ʧ��");
			}
		});
	}
    
    
    	$(function(){
    		$.ajax({
    			url:"${pageContext.request.contextPath}/system/user/getalluser",
    			type:"GET",
    			dataType:"json",
    			success:function(data){
    			for(var i = 0;i<data.length;i++){
  var dom ='<tr><td>'+data[i].userid+'</td><td>'+data[i].username+'</td><td>'+data[i].password+'</td><td><a href="${pageContext.request.contextPath}/user/getUser?userid='+data[i].userid+'">'+"�༭ |"+'</a><a href="javascript:del('+data[i].userid+')">'+"ɾ��"+'</a></td></tr>'; 
    					$("#table").append(dom) ;
    				}		
    			},
    			error:function(){
    				alert("error");
    			}
    		});
    	});
    </script>
  </body>
</html>

